package com.goldgov.mobile;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.goldgov.kcloud.core.json.JsonQueryObject;
import com.goldgov.materials.service.Materials;
import com.goldgov.materials.service.MaterialsQuery;
import com.goldgov.materials.service.MaterialsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/mobile/open/materials")
@Api("学习资料服务接口")
public class MaterialsForMobileController {

	@Autowired
	private MaterialsService service;
	
	@GetMapping("/")
	@ApiOperation(value = "查询多条学习资料", notes ="学习资料列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "searchPublishState", value = "发布状态查询条件", paramType = "query"),
		 @ApiImplicitParam(name = "searchCreateDateBegin", value = "学习资料查询开始时间", paramType = "query"),
		 @ApiImplicitParam(name = "searchMaterialsTitle", value = "学习资料名称", paramType = "query"),
		 @ApiImplicitParam(name = "searchCreateDateEnd", value = "学习资料查询结束时间", paramType = "query")})
	public JsonQueryObject<Materials> listMaterials(@ApiIgnore MaterialsQuery query,HttpServletRequest request){
		query.setSearchPublishState(MaterialsQuery.PUBLISH_STATE_YES);
		List<Materials> list = service.listMaterials(query);
		query.setResultList(list);
		return new JsonQueryObject<>(query);
	}
	
}